import java.util.Scanner;
import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 10];
        for(int i = 1; i <= n; ++ i ) {
            a[i] = sc.nextInt();
        }
        long ans = 0;

        while(n >= 3) {
            ans++;
            for(int i = 1; i + 2 <= n; ++ i ) {
                int tt = a[i] + a[i + 1] + a[i + 2];
                if(tt <= ans * 3) {
                    a[i] = tt;
                    for(int j = i + 1; j + 2<= n; ++ j ) {
                        a[j] = a[j + 2];
                    }
                    n -= 2;
                }
            }
        }
        System.out.println(ans);
    }
}